package com.hooper.login.config;

import com.hooper.login.aop.TokenInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2022/12/28/12:16
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {


    @Bean
    public TokenInterceptor tokenInterceptor() {
        return new TokenInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor()).order(1);
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
